import Vue from 'vue'
import App from './App'

import router from './router';

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

import axios from 'axios';
import VueAxios from 'vue-axios'

import 'lib-flexible/flexible.js'

Vue.use(router);
Vue.use(ElementUI);
Vue.use(VueAxios,axios);

router.beforeEach((to, from, next) => {
  if (to.path === '/login') {
    localStorage.removeItem('token_only');
  }
  let user = localStorage.getItem("token_only")

  if (user===null && to.path !== '/login' && to.path!=='/findpwd') {
    next({ path: '/login' })
  } else {
    next()
  }
})

new Vue({
  el: '#app',
  router,
  render: h => h(App)
});

